using System;
using System.Collections;
using System.Globalization;
using UnityEngine;

public class TimeManager : MonoBehaviour
{
	public static TimeManager sharedInstance;

	private string timeURL = "http://cgi.im.qq.com/cgi-bin/cgi_svrtime";

	private DateTime _dateTime;

	private void Awake()
	{
		if (sharedInstance == null)
		{
			sharedInstance = this;
		}
		else if (sharedInstance != this)
		{
			UnityEngine.Object.Destroy(base.gameObject);
		}
		UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
	}

	public IEnumerator GetTime()
	{
        
        yield return 0;
        //yield return new WWW(timeURL);
        //if (!DateTime.TryParseExact(PlayerPrefs.GetString("_date"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out _dateTime))
        //{
        _dateTime = DateTime.Now;
        //}
    }

	private void Start()
	{
		StartCoroutine("GetTime");
	}

	public string GetCurrentDateNow()
	{
		return _dateTime.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
	}

	public string GetCurrentTimeNow()
	{
		return _dateTime.ToString("T", DateTimeFormatInfo.InvariantInfo);
	}
}
